﻿using System;
using System.Data;
using System.Data.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;

namespace Shuba.Data
{
	public class Reports
	{
        public Reports()
		{
		}

        public DataSet RPT_REKAP_PER_OFFICER_PER_UNIT(string UnitCode, DateTime StartDate, DateTime EndDate)
		{
            Database db = DBConnection.CreateDatabase();
            DbCommand cmd = db.GetStoredProcCommand("RPT_REKAP_PER_OFFICER_PER_UNIT");
            cmd.CommandTimeout = 600;

            db.AddInParameter(cmd, "@UNIT_CODE", DbType.String, UnitCode);
            db.AddInParameter(cmd, "@START_DATE", DbType.DateTime, StartDate);
            db.AddInParameter(cmd, "@END_DATE", DbType.DateTime, EndDate);

            DataSet ds = db.ExecuteDataSet(cmd);

            return ds;
		}

        public DataSet RPT_REKAP_PER_UNIT_CROSSTAB(string UnitCode, string sMonth, string sYear)
        {
            Database db = DBConnection.CreateDatabase();
            DbCommand cmd = db.GetStoredProcCommand("RPT_REKAP_PER_UNIT_CROSSTAB");
            cmd.CommandTimeout = 600; 

            db.AddInParameter(cmd, "@UNIT_CODE", DbType.String, UnitCode);
            db.AddInParameter(cmd, "@PROSPECT_MONTH", DbType.String, sMonth);
            db.AddInParameter(cmd, "@PROSPECT_YEAR", DbType.String, sYear);

            DataSet ds = db.ExecuteDataSet(cmd);

            return ds;
        }

        public DataSet RPT_MONTHLY_PERFORMANCE(string RegionID, string ClusterID, string UnitCode, string sMonth, string sYear)
        {
            Database db = DBConnection.CreateDatabase();
            DbCommand cmd = db.GetStoredProcCommand("RPT_MONTHLY_PERFORMANCE");
            cmd.CommandTimeout = 600;

            db.AddInParameter(cmd, "@REGION_ID", DbType.String, RegionID);
            db.AddInParameter(cmd, "@CLUSTER_ID", DbType.String, ClusterID);
            db.AddInParameter(cmd, "@BRANCH_ID", DbType.String, UnitCode);
            db.AddInParameter(cmd, "@PROSPECT_MONTH", DbType.String, sMonth);
            db.AddInParameter(cmd, "@PROSPECT_YEAR", DbType.String, sYear);

            DataSet ds = db.ExecuteDataSet(cmd);

            return ds;
        }

        public DataSet RPT_PERIOD_PERFORMANCE(string RegionID, string ClusterID, string UnitCode, DateTime StartDate, DateTime EndDate)
        {
            Database db = DBConnection.CreateDatabase();
            DbCommand cmd = db.GetStoredProcCommand("RPT_PERIOD_PERFORMANCE");
            cmd.CommandTimeout = 600;

            db.AddInParameter(cmd, "@REGION_ID", DbType.String, RegionID);
            db.AddInParameter(cmd, "@CLUSTER_ID", DbType.String, ClusterID);
            db.AddInParameter(cmd, "@BRANCH_ID", DbType.String, UnitCode);
            db.AddInParameter(cmd, "@START_DATE", DbType.DateTime, StartDate);
            db.AddInParameter(cmd, "@END_DATE", DbType.DateTime, EndDate);

            DataSet ds = db.ExecuteDataSet(cmd);

            return ds;
        }

    }
}
